﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace BingleMaps.Controls
{
	public class CaptionButton : ContentControl
	{
		public event EventHandler<GestureEventArgs> Tap;

		public CaptionButton()
		{
			DefaultStyleKey = typeof(CaptionButton);
		}

		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			var button = GetTemplateChild("HyperlinkButton") as HyperlinkButton;
			if (button == null) return;
			button.Tap += Tap;
		}

		public string Caption
		{
			get { return (string)GetValue(CaptionProperty); }
			set { SetValue(CaptionProperty, value); }
		}

		public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register(
			"Caption",
			typeof(string),
			typeof(CaptionButton),
			null);

		public Uri NavigateUri
		{
			get { return (Uri)GetValue(NavigateUriProperty); }
			set { SetValue(NavigateUriProperty, value); }
		}

		public static readonly DependencyProperty NavigateUriProperty = DependencyProperty.Register(
			"NavigateUri",
			typeof(Uri),
			typeof(CaptionButton),
			null);
	}
}
